var utils = require('../../../utils/util.js')
var c = require('../../../utils/config.js')
Page({

    /**
     * 页面的初始数据
     */
    data: {
        messageList: [],
        select: 0,
        page:1,
    },
    onLoad: function (options) {
        // this.getData()
    },
    tabnav: function(e) {
        let k = e.currentTarget.dataset.index;
        this.setData({
            select: k
        })
    },
    //下拉刷新
    onPullDownRefresh: function () {
        this.setData({
            historyList: [],
            page: 1,
        });
        this.getData();
    },
    //上拉加载
    onReachBottom: function () {
        this.getData();
    },
    getData: function () {
        var that = this;
        var token = wx.getStorageSync("userinfo").wap_token;
        var data = {
            url: "/wsgoods/usermessage/lists",
            token: token,
            page: that.data.page,
            limit: 10,

        };
        utils.request(data).then(function (res) {
            if (res.code == 0) {
                var data = res.data;
                if (data.length > 0) {
                    that.setData({
                        page: that.data.page + 1
                    });
                }
                that.setData({
                    messageList: that.data.messageList.concat(data),
                });
            } else {

            }
            wx.stopPullDownRefresh();
        });
    },
    
})